package com.test.chatdemo.service.impl;

import com.test.chatdemo.mapper.UserMapper;
import com.test.chatdemo.pojo.NewUser;
import com.test.chatdemo.pojo.User;
import com.test.chatdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;


@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;


    //登录
    public User login(User user) {
        User getUser = userMapper.getUser(user);
        return getUser;
    }

    //注册
    public void register(User user) {
        userMapper.register(user);
    }

    @Override
    public String getUserName(User user) {

        String name = user.getName();
        User getuser = userMapper.getUserName(name);
        if(getuser != null) {
            return getuser.getName();
        }
        return null;

    }

    //修改密码
    public void changePassword(NewUser newUser) {

        userMapper.changePassword(newUser);

    }

    @Override
    public User getUser(User user) {
        User getuser = userMapper.getUser(user);

        return getuser;
    }


}
